package org.teachertools.web.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.teachertools.data.Eleve;
import org.teachertools.services.EleveService;
import org.teachertools.web.forms.EleveForm;
import org.teachertools.web.forms.EleveFormMapping;

public class EleveViewAction extends CommonAction {
    @Override
    protected ActionForward process(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        EleveService eleveService = this.getServiceLocator().getEleveService();
        Long id = Long.parseLong(request.getParameter("id"));
        Eleve eleve = eleveService.get(id);
        EleveFormMapping.mappingDTOToForm(eleve, (EleveForm) form);
        ((EleveForm) form).setIsUpdate(Boolean.TRUE);
        return (mapping.findForward(CONTINUE));
    }
}
